module.exports = function (grunt) {
    grunt.initConfig({
        jade: {
            compile: {
                files: [
                    {expand: true, cwd: 'src/jade', src: ['*.jade'], dest: 'build', ext: '.html'}
                ]
            }
        },
        sass: {
            compile: {
                files: [
                    {expand: true, cwd: 'src/sass', src: ['*.scss'], dest: 'build/css', ext:'.css'}
                ]
            }
        },
        coffee: {
            compile: {
                files: [
                    {expand: true, cwd: 'src/coffee', src: ['*.coffee'], dest: 'build/script', ext:'.js'}
                ]
            }
        },
        copy: {
            copy_lib: {
                files: [
                    {expand: true, src: ['lib/**'], dest: 'build'}
                ]
            },
            copy_img: {
                files: [
                    {expand: true, cwd: 'src', src: ['img/**'], dest: 'build'}
                ]
            }
        },
        watch: {
            jade: {files: ['src/jade/**.jade', 'src/jade/view/**.jade'], tasks: ['jade']},
            sass: {files: ['src/sass/**'], tasks: ['sass']},
            coffee: {files: ['src/coffee/**.coffee'], tasks: ['coffee']},
            copy_lib: {files: ['lib/**'], tasks: ['copy:copy_lib']},
            copy_img: {files: ['src/img/**'], tasks: ['copy:copy_img']}
        }
    });

    // 加载任务
    grunt.loadNpmTasks('grunt-contrib-copy');
    grunt.loadNpmTasks('grunt-contrib-jade');
    grunt.loadNpmTasks('grunt-contrib-watch');
    grunt.loadNpmTasks('grunt-contrib-coffee');
    grunt.loadNpmTasks('grunt-contrib-sass');

    // 定义任务

    grunt.registerTask('default',['jade','sass','coffee','copy']);
};